
    	//创建控制器
    	app.controller("brandController",function($scope,$controller,$http,brandService){
			
    		$controller('baseController',{$scope:$scope});//伪继承
    		

    		
    		//分页+模糊查询
    		$scope.findLike ={};//声明参数
    		$scope.findPageAll=function(pageNum,pageSize){
    		
    		 	brandService.findPageAll(pageNum,pageSize,$scope.findLike).success(
    				function(response) {
    					//1.把当前页数据赋给pageList
    					$scope.pageList=response.result;
    					//2.把总页数赋给分页控件
    					$scope.paginationConf.totalItems=response.total;
    					
					}		
    			);
    		}
    		
    
    		
    		//添加/修改品牌信息
    		$scope.addAndUpdateBrand=function(){
    			//判断需要访问的方法
    			var object = null;
    			if ($scope.saveBrand.id!=null) {
    				object=brandService.updateBrand($scope.saveBrand);
    			}else {
					object=brandService.addBrand($scope.saveBrand);
				}
    			
    			/*  var object = null;
    			 if($scope.saveBrand.id!=null){
    				 object=$http.post("../brand/updateBrand.do",$scope.saveBrand)
    			 } */
    			 object.success(
    				function(response){
    					if (response.success) {
							$scope.reloadList();//重新加载页面
						}else {
							alert(response.message);
						}
    				}		
    			);
    		}
    		
    		
			//回写品牌信息
    		$scope.findByBrandId=function(id){
    			brandService.findByBrandId(id).success(
    				function(response){
    					//回写数据
    					$scope.saveBrand=response;
    				}		
    			);
    		}
    		
    		
    		
    		//删除选中的品牌信息
    		//2、删除
    		$scope.deleteBrand=function(){
    			if (confirm("确定删除选中项？")) {
					brandService.deleteBrand($scope.ids).success(
						function(response) {
							if (response.success) {
								//重新加载页面
								$scope.reloadList();
							}else {
								//提示失败信息
								alert(response.message);
							}
						}		
					);
				}
    		}
    		
    		
    	});